package org.springblade.modules.notice.core.conditon.impl;

import org.springblade.modules.notice.core.conditon.TriggerConditionFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author ysq
 * @Date 2024/12/06
 * @Description 停梯的任务已签到开始后，作业2/4小时，未签退
 */
@Component
public class Condition10And11Handler implements TriggerConditionFactory {
	@Resource
	private JdbcTemplate jdbcTemplate;

	private static final String C_10_11_SQL = "SELECT ISNULL(SUM( sign_out_status )) AS result FROM blade_maintain_sign WHERE plan_id = ? GROUP BY plan_id";

	@Override
	public boolean isTrigger(Long bizId) {
		try {
			return jdbcTemplate.queryForObject(C_10_11_SQL, new Object[]{bizId}, boolean.class);
		} catch (DataAccessException e) {
			return false;
		}
	}
}
